//
//  MediaPlayerViewController.m
//  MJAVFoundationDemo
//
//  Created by apple on 16/9/19.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MediaPlayerViewController.h"
#import "ZDCtlView.h"
@interface MediaPlayerViewController ()
@property(nonatomic,strong)UIView *playingView;
@property(nonatomic,strong)ZDCtlView *controlView;
@end

@implementation MediaPlayerViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title=@"视频播放";
    self.view.backgroundColor=[UIColor redColor];
    [self.view addSubview:self.playingView];
    [self.playingView addSubview:self.controlView];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(Full) name:@"Full" object:nil];
}
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
-(void)Full
{
//    self.currentPlayerLayer.transform = CATransform3DMakeRotation(M_PI/2, 0, 0, 1);
//    self.currentPlayerLayer.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
//        self.navigationController.navigationBarHidden=YES;
}
-(UIView *)playingView
{
    if (!_playingView)
    {
        _playingView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, KWIDTH, 250)];
        _playingView.backgroundColor=[UIColor blackColor];
        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(appearControlView)];
        [_playingView addGestureRecognizer:tap];
    }
    return _playingView;
}

-(ZDCtlView *)controlView
{
    if (!_controlView)
    {
        _controlView=[[ZDCtlView alloc]initWithFrame:CGRectMake(0, CGRectGetHeight(self.playingView.frame)-40, KWIDTH, 40)];
        _controlView.isAppear=YES;
        _controlView.backgroundColor=[UIColor lightGrayColor];
    }
    return _controlView;
}

#pragma mark--控制小视图的出现
-(void)appearControlView
{
    if (_controlView.isAppear)
    {
        [UIView animateWithDuration:0.5 animations:^{
            _controlView.frame=CGRectMake(0,  CGRectGetHeight(self.playingView.frame), KWIDTH, 0);

        }];
        _controlView.isAppear=NO;
    }else
    {
        [UIView animateWithDuration:0.5 animations:^{
            _controlView.frame=CGRectMake(0, CGRectGetHeight(self.playingView.frame)-40, KWIDTH, 40);

        }];
        _controlView.isAppear=YES;

    }
}
@end
